package com.zlp.partice;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Day20220116 {

    List<Day0901.ListNode> list = new ArrayList<>();
    public void Solution(Day0901.ListNode head) {
      while (head != null){
          list.add(head);
          head = head.next;
      }
    }

    public int getRandom() {
        int nextInt = new Random().nextInt(list.size());
        return list.get(nextInt).val;
    }
}
